"""
文件操作工具模块
"""
import logging

import oss2

from .exceptions import OSSException


class OSSManager:
    """OSS 操作管理器"""
    
    def __init__(self, bucket: oss2.Bucket):
        self.bucket = bucket
        self.logger = logging.getLogger(f"{__name__}.{self.__class__.__name__}")

    def generate_signed_url(self, object_key: str, expire_seconds: int = 30 * 24 * 60 * 60) -> str:
        """生成预签名 URL"""
        try:
            return self.bucket.sign_url('GET', object_key, expire_seconds)
        except Exception as e:
            raise OSSException(f"生成预签名 URL 失败: {str(e)}")
